import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsInt, IsNotEmpty, IsOptional } from "class-validator";

export class CreateMainlyCategoryDto {
    @ApiProperty({ example: '历史', description: '类别名称' })
    @IsNotEmpty({
        message: '名称不能为空'
    })
    name: string

    @ApiProperty({ example: 'history', description: '描述' })
    description: string

    @ApiProperty({ example: 'true', description: '是否置顶' })
    isPoint: boolean

    @ApiProperty({ example: '0或1', description: '等级' })
    @IsNotEmpty({
        message: '等级不能为空'
    })
    level: string

    @ApiProperty({ example: '100000', description: '父级id' })
    @IsOptional()
    @Type(() => Number)
    @IsInt()
    parentId: number

    @ApiProperty({ example: '100000', description: '用户id' })
    @IsOptional()
    @Type(() => Number)
    @IsInt()
    userId: number
}

export class EditMainlyCategoryDto extends CreateMainlyCategoryDto {
    @ApiProperty({ example: '1111', description: '类别id' })
    @IsNotEmpty({
        message: '类别id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number
}

export class DeleteMainlyCategoryDto {
    @ApiProperty({ example: '1111', description: '类别id' })
    @IsNotEmpty({
        message: '类别id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    id: number
}

export class FindUserAllDto {
    @ApiProperty({ example: '1111', description: '用户id' })
    @IsNotEmpty({
        message: '用户id不能为空'
    })
    @Type(() => Number)
    @IsInt()
    userId: number

    @ApiProperty({ example: '0或1', description: '等级' })
    @IsNotEmpty({
        message: '等级不能为空'
    })
    level: string
}
